package com.rx.mgt.service;

import com.rx.mgt.dao.SpamDao;
import com.rx.mgt.domain.Spam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * Created by zxj on 2017/5/31.
 */
@Service
public class SpamService {

    @Autowired
    private SpamDao spamDao;

    @Transactional
    public Spam getSpamByDomain(String domain) {
        return spamDao.getSpanByDomain(domain);
    }

    @Transactional(readOnly = false,propagation = Propagation.REQUIRED)
    public int saveOrUpdate(Spam spam) {
        spam.setInsert_date(new Date());
        spamDao.saveOrUpdate(spam);
        if(spam!=null){
            return 1;
        }else{
            return 0;
        }
    }

}
